export default {
    namespaced: true,
    //存储数据的容器
    state: {
        count: 1,
    },
    //存储只读计算属性数据的容器
    getters: {
        judge(state) {
            return state.count % 2 === 1 ? "奇数" : "偶数";
        },
    },
    actions: {
        increment({ commit }, val) {
            console.log("increment的入参是", val);

            commit("INCREMENT", val);
        },
        decrement({ commit }, val) {
            commit("DECREMENT", val);
        },
        incrAsync(store, val) {

            setTimeout(() => {
                console.log(store);
                store.commit("INCREMENT", val);
            }, 1000);
        }
    },
    mutations: {
        INCREMENT(state, val) {
            state.count += val;
        },
        DECREMENT(state, val) {
            state.count -= val;
        }
    },
};